#include <stdio.h>
#include <stdlib.h>

int main() {
	int arr[] = {0, -3, 6, 8, -20, 21, 8, -9, 10, -1, 3, 6, 5};
    //存储最大值
    int max = arr[0];
    int i, j;
    int tempSum = 0;
    int sizeOfArr = sizeof(arr) / sizeof(int);
    for (int i = 0; i < sizeOfArr; i++) {
        tempSum = 0;
        for (int j = i; j < sizeOfArr; ++j) {
            tempSum += arr[j];
            if (tempSum > max) {
                max = tempSum;
            }
        }
    }
    printf("max = %d \n", max);
    return 0;
}